package com.software.controller;


import java.util.List;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;

import com.software.model.ModelCreate;
import com.software.service.UserService;

@Controller("userController")
@RequestMapping(value = "/login/*") 
public class Login  extends BaseController{
	
	@Autowired  
    private UserService userService;
	
	private int seq = 1;
	
	@RequestMapping(value = "check", method = RequestMethod.GET)  
    public String toLogin(HttpServletResponse res, HttpServletRequest req) throws Exception {  
//  
//        AdminUser user = new AdminUser();
//        user.setId(seq++);
//        user.setNickname("test");
//        user.setState(0);
//        this.userService.insertUser(user);  
  
     //   map.put("result", result);  
  
        return "/agent/drm_main";
    }  
	
	
	@RequestMapping(value = "agency", method = RequestMethod.GET)  
    public String agency(HttpServletResponse res, HttpServletRequest req) throws Exception {  
  
  
     //   map.put("result", result);  
  
        return "/agent/agency_set";
    } 
	
	@RequestMapping(value = "drm", method = RequestMethod.GET)  
    public String drm(HttpServletResponse res, HttpServletRequest req) throws Exception {  
  
  
     //   map.put("result", result);  
  
        return "/agent/menu";
    }
	
	@RequestMapping(value = "infoManage", method = RequestMethod.GET)  
    public String infoManage(HttpServletResponse res, HttpServletRequest req) throws Exception {  
  
  
     //   map.put("result", result);  
  
        return "/agent/infoManage";
    } 
	
	@RequestMapping(value = "sql", method = RequestMethod.GET)
    public void sql(HttpServletResponse res, HttpServletRequest req) throws Exception { 
		
		String ary[] = {"drm_course"};
		for (String tab_Name : ary) {
			System.out.println("/////////////////////"+tab_Name+"////////////////////////////////");
			List<ModelCreate> sqllist = userService.queryModel(tab_Name);
	    }
    }
	
	@RequestMapping(value = "buildSql", method = RequestMethod.GET)
    public void buildSql(HttpServletResponse res, HttpServletRequest req) throws Exception { 
		
		String ary[] = {"drm_user"};
		for (String tab_Name : ary) {
			System.out.println("/////////////////////"+tab_Name+"////////////////////////////////");
			userService.buildSQLSearch(tab_Name);
	    }
		
		for (String tab_Name : ary) {
			System.out.println("/////////////////////"+tab_Name+"////////////////////////////////");
			userService.buildSQLInsert(tab_Name);
	    }
    } 
	
	@RequestMapping(value = "drmInfo", method = RequestMethod.GET)  
    public String drmInfoIndex(HttpServletResponse res, HttpServletRequest req) throws Exception {  
  
  
     //   map.put("result", result);  
  
        return "/agent/info";
    }
}
